package com.zuxia.action;

import java.io.IOException;
import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.zuxia.impDao.StaffindoDAO;
import com.zuxia.iservices.PeopleManagementServicesI;
import com.zuxia.po.Staffindo;

public class StaffindoAction extends BaseAction{
	private String name;
	private String selSex;
	private String inpPhone;
	private String selDepartment;
	private String selPosition;
	private String inpCardId;
	private String txtAddress;
	/**
	 * 员工id
	 */
	private Integer siid;
	
	/**
	 * 以下三个是分页查询员工用到的字段属性
	 */
	private String pageNumber;
	private String limit;
	private String serachstuName;
	
	private PeopleManagementServicesI peopleManagementServices;
	
	//查询员工信息
	public void showAllStaffindo(){
		System.out.println("查询所有员工");
		List<Staffindo> list=new StaffindoDAO().findAll();
		String json = JSONArray.toJSONString(list);
		try {
			getResponse().getWriter().print(json);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	/**
	 * 修改员工信息
	 */
	public void updatestaffInfo() {
		System.out.println("即将修改的员工信息如下，最后一个是员工id："+name+"-"+selSex+"-"+inpPhone+"-"+selDepartment+"-"+selPosition+"-"+inpCardId+"-"+txtAddress+"-"+siid);
		//调用人员管理业务中的修改员工的方法
		String message = peopleManagementServices.updatestaffInfo(name, selSex, inpPhone, selDepartment, selPosition, inpCardId, txtAddress,siid);
		System.out.println(message);
		try {
			getResponse().getWriter().println(message);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 删除员工信息
	 */
	public void delStaffById() {
		System.out.println("即将删除员工id："+siid);
		//调用人员管理业务中的删除员工的方法
		String message = peopleManagementServices.delStaffById(siid);
		System.out.println(message);
		try {
			getResponse().getWriter().println(message);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 添加员工信息
	 * 谌华勇
	 *2018年11月14日上午11:58:19
	 */
	public void addstaffInfo() {
		System.out.println("即将插入的员工信息如下："+name+"-"+selSex+"-"+inpPhone+"-"+selDepartment+"-"+selPosition+"-"+inpCardId+"-"+txtAddress);
		//调用人员管理业务中的添加员工的方法
		String message = peopleManagementServices.addstaffInfo(name, selSex, inpPhone, selDepartment, selPosition, inpCardId, txtAddress);
		System.out.println(message);
		try {
			getResponse().getWriter().println(message);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	/**
	 *分页查询员工信息
	 * @author 谌华勇
	 * 2018年11月16日上午10:37:36
	 */
	public void selStaffByPageModel() {
		String json = peopleManagementServices.selStaffByPageModel(pageNumber, limit, serachstuName);
		try {
			getResponse().getWriter().println(json);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSelSex() {
		return selSex;
	}
	public void setSelSex(String selSex) {
		this.selSex = selSex;
	}
	public String getInpPhone() {
		return inpPhone;
	}
	public void setInpPhone(String inpPhone) {
		this.inpPhone = inpPhone;
	}
	public String getSelDepartment() {
		return selDepartment;
	}
	public void setSelDepartment(String selDepartment) {
		this.selDepartment = selDepartment;
	}
	public String getSelPosition() {
		return selPosition;
	}
	public void setSelPosition(String selPosition) {
		this.selPosition = selPosition;
	}
	public String getInpCardId() {
		return inpCardId;
	}
	public void setInpCardId(String inpCardId) {
		this.inpCardId = inpCardId;
	}
	public String getTxtAddress() {
		return txtAddress;
	}
	public void setTxtAddress(String txtAddress) {
		this.txtAddress = txtAddress;
	}
	public PeopleManagementServicesI getPeopleManagementServices() {
		return peopleManagementServices;
	}
	public void setPeopleManagementServices(PeopleManagementServicesI peopleManagementServices) {
		this.peopleManagementServices = peopleManagementServices;
	}
	public String getPageNumber() {
		return pageNumber;
	}
	public void setPageNumber(String pageNumber) {
		this.pageNumber = pageNumber;
	}
	public String getLimit() {
		return limit;
	}
	public void setLimit(String limit) {
		this.limit = limit;
	}
	public String getSerachstuName() {
		return serachstuName;
	}
	public void setSerachstuName(String serachstuName) {
		this.serachstuName = serachstuName;
	}
	public Integer getSiid() {
		return siid;
	}
	public void setSiid(Integer siid) {
		this.siid = siid;
	}
	
}
